package org.jackysoft.report;

import org.apache.commons.collections.Predicate;
import org.jackysoft.entity.ArmItem;
import org.jackysoft.entity.Product;
import org.jackysoft.util.StringUtils;
import org.springframework.stereotype.Component;

/**
 * <dd>根据编码判断两个数据项是否是相同的
 * <dd>作为累计统计的依据
 * */
@Component(ReportConstant.ArmItemEqualPredicate)
public class ArmItemEqualPredicate extends AbstractArmEqualsPredicate {

	private Product host;
	
	public ArmItemEqualPredicate(Product host) {
		this.host = host;
	}

	public ArmItemEqualPredicate() {
	}

	@Override
	public boolean evaluate(Object arg0) {
		ArmItem i = (ArmItem) arg0;
		String code1 = StringUtils.lowerCase(StringUtils.trim(i.getHost().getCode()));
		String code2 = StringUtils.lowerCase(StringUtils.trim(this.host.getCode()));
		return code1.equals(code2);
	}

	public void setHost(Product host) {
		this.host = host;
		
	}

}
